<!DOCTYPE html>
<html lang="en">
<head>
    <style>
        .divcss5{ border:1px solid #F00; width:200px; height:100px}
    </style>
    <link rel="stylesheet" href="css/foot.css"/>
    <link rel="stylesheet" href="css/head.css"/>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <script type="text/javascript" src="js/base-v1.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/jquery-1.2.6.min.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/cookie.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/common.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/jquery.cookie.js" charset="utf-8"></script>
    <script type="text/javascript" src="s/base-2011.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/jquery.min.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/jquery-extend.js"></script>
    <script type="text/javascript" src="js/lib-v1.js" charset="utf-8"></script>
    <link href="css/prodList.css" rel="stylesheet" type="text/css">
    <link href="css/prodInfo.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="js/logout.js"></script>
    <script type="text/javascript" src="js/productinfo.js"></script>
    <meta charset="UTF-8">
    <title>商品分页</title>
    <script type="text/javascript">
        var userId="";
        var productId="";
        window.onload=function(){

            var localUrl=decodeURI(window.location.href);
            //alert(localUrl);
            productId=localUrl.split("?")[1].split("=")[1];
            $.ajax({
                url:"http://www.easyhouse.com/products/item/"+productId,
                dataType:"json",
                type:"POST",
                success:function(data){
                    //图片
                    var imgUrl=data.imgUrl;
                    var productPrice = data.productPrice;
                    var houseArea = data.houseArea;
                    var unitPrice = data.productPrice/data.houseArea;
                    unitPrice = unitPrice.toFixed(2);
                    productId=data.productId;
                    document.getElementById("prod_img").src=data.imgUrl;
                    document.getElementById("prod_area").innerText=data.houseArea;
                    document.getElementById("prod_unitprice").innerText=unitPrice;
                    document.getElementById("prod_name").innerText=data.houseName;
                    document.getElementById("prod_desc").innerText=data.houseDescription;
                    document.getElementById("prod_pric").innerText=data.productPrice;
                    document.getElementById("prod_addr").innerText=data.houseAddr;
                    document.getElementById("prod_province").innerText=data.addrProvince;
                    document.getElementById("prod_district").innerText=data.addrDistrict;
                }
            });
            var _ticket = $.cookie("EM_TICKET");
            //alert(_ticket);
            if(!_ticket){
                return ;
            }

                //当dataType类型为jsonp时，jQuery就会自动在请求链接上增加一个callback的参数
                $.ajax({
                    url : "http://www.easyhouse.com/user/query/" + _ticket,
                    dataType : "json",
                    type : "GET",
                    success : function(data){
                        //alert("好啊2");
                        if(data.status == 200){
                            var _data = JSON.parse(data.data);//jackson
                            var html =_data.userName+"，欢迎来到京淘！<a href=\"javascript:void(0)\" class=\"link-logout\" onclick='logout()'>[退出]</a>  \|<a href=\"http://www.easyhouse.com/manage.html\" class=\"link-logout\">[后台]</a>";
                            userId=_data.userId;
                            $("#loginbar").html(html);
                        }

                    },
                    error : function(){
                        alert('index error.');
                    }
                });
            }

        function addCart(){
            if(userId==""){
                window.location.href="login.html";
                return;
            }
            var num=document.getElementById("buyNumInp").value;
            alert(num);
            $.ajax({
                url:"http://www.easyhouse.com/cart/save?userId="+userId+"&productId="+productId+"&num="+num,
                dataType:"json",
                type:"GET",
                success:function (data){

                    if(data.status==200){
                        window.location.href="http://www.easyhouse.com/mycart.html?userId="+userId;
                    }else{
                        alert("新购物车失败");
                    }
                },
                error:function () {
                    alert("算了吧");
                }
            });
        }
        function search(a){
            var query=document.getElementById(a).value;
            //alert(query);
            window.location.href="./search.html?query="+query;

        }
    </script>
</head>
<body>
<div id="common_head">
    <div id="line1">
        <div id="content">
            <li class="fore1" id="loginbar" clstag="homepage|keycount|home2013|01b">
                <span id="head_span"\\\x><a href="./login.html">登录</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="./regist.html">注册</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="./manage.html">后台</a></span>

            </li>
        </div>
    </div>
    <div id="line2">
        <img id="logo" src="img/head/logo.jpg"/>
        <input type="text" value="" accesskey="s" id="key" autocomplete="off" onkeydown="javascript:if(event.keyCode==13) search('key');"/>
        <input type="button" value="搜 索" onclick="search('key')"/>
        <span id="goto">
			<a id="goto_order" href="./myorder.html">我的订单</a>
			<a id="goto_cart" href="./mycart.html">我的购物车</a>
		</span>
        <img id="erwm" src="img/head/qr.jpg"/>
    </div>
    <div id="line3">
        <div id="content">
            <ul>
                <li><a href="#">首页</a></li>
                <li><a href="./product-list.html?page=1&rows=5">全部商品</a></li>
                <li><a href="/web/sekill/list">秒杀商品</a></li>
                <li><a href="#">电脑平板</a></li>
                <li><a href="#">家用电器</a></li>
                <li><a href="#">汽车用品</a></li>
                <li><a href="#">食品饮料</a></li>
                <li><a href="#">图书杂志</a></li>
                <li><a href="#">服装服饰</a></li>
                <li><a href="#">理财产品</a></li>
            </ul>
        </div>
    </div>
</div>
<div id="warp">
    <div id="left">
        <div id="left_top">
            <img src="" id="prod_img">
        </div>
        <div id="left_bottom">

        </div>
    </div>
    <div id="right">
        <div id="right_top">
            <span id="prod_name"><br/></span>
            <br>
            <span id="prod_desc"><br/></span>
        </div>
        <div id="right_middle">
				<span id="right_middle_span">
                    所在区域&nbsp;:&nbsp;<span id="prod_province"></span>&nbsp;&nbsp;<span id="prod_district"></span><br/>
                    详细区域&nbsp;:&nbsp;<span id="prod_addr"></span><br/>
                    面积&nbsp;:&nbsp;<span id="prod_area"></span>平米<br/>
                    总价&nbsp;:&nbsp;<span class="price_red" id="prod_pric"></span>元<br/>
                    单价&nbsp;:&nbsp;<span id="prod_unitprice"></span>/平米<br/>

                </span>
        </div>
        <div id="right_bottom">
            <input class="add_cart_but" type="button" onclick="addCart()"/>
        </div>
    </div>
</div>
<div id="common_foot">
    <p>
        Copyright © 2011-2015 达内软件技术有限公司 版权所有 保留一切权利 苏B2-20130048号 | 京ICP备09062682号-9
        <br>
        网络文化经营许可证苏网文[2012]0401-019号
    </p>
</div>
</body>
</html>